// JScript File

var url = "rtsp://mafreebox.freebox.fr/freeboxtv/stream?id=201";

function launchMultiposte() {
    if (System.Gadget.Settings.read("player") == "homeplayer") {
        homeplayer_path = System.Gadget.Settings.readString("homeplayerPath");
	    //if (System.Gadget.Settings.read("fai") == "free") {
            System.Shell.execute(homeplayer_path);
        /*} else if (System.Gadget.Settings.read("fai") == "neuf") {
            System.Shell.execute(homeplayer_path, "");
	    } else {
	        System.Shell.execute(homeplayer_path, "");
	    }*/
    } else {
        vlc_path = System.Gadget.Settings.readString("vlcPath");
	    if (System.Gadget.Settings.read("fai") == "free") {
            System.Shell.execute(vlc_path, "http://mafreebox.freebox.fr/freeboxtv/playlist.m3u");
        } else if (System.Gadget.Settings.read("fai") == "free-nd") {
            System.Shell.execute(vlc_path, '-vvv "'+System.Gadget.path+'\\FreeboxTV.m3u"');
        } else if (System.Gadget.Settings.read("fai") == "neuf") {
            System.Shell.execute(vlc_path, "-vvv http://televisionsurpc.neuf.fr/televisionsurpc.m3u");
        } else if (System.Gadget.Settings.read("fai") == "alice") {
            System.Shell.execute(vlc_path, '-vvv "'+System.Gadget.path+'\\Alice.m3u"');
	    } else {
	        System.Shell.execute(vlc_path, '-vvv "'+System.Gadget.path+'\\playlist.m3u"');
	    }
    }
}

function launchVLC(obj) {
    var tmp = document.getElementById(obj).innerHTML;
    var channel_name;
    vlc_path = System.Gadget.Settings.readString("vlcPath");
    
    //var isOK = GetPing();
    //var isOK = true;
    if (tmp.substring(0,1) == '<') {
        var debut = tmp.indexOf('alt=',0)+4;
        var fin = tmp.indexOf(' src=',debut);
        channel_name = tmp.substring(debut,fin);
    } else {
        channel_name = tmp;
    }
    launchVLCChannel(channel_name);
}

function launchVLCChannel(channel_name) {
    url = 0;
    var fai = System.Gadget.Settings.read("fai");
    switch (fai) {
    case "free":
        encodage = System.Gadget.Settings.read("encodage");
        switch (encodage) {
	    case "mpeg2":
            setFreeboxUrlMpeg2(channel_name);
            break;
        case "mpeg24":
            setFreeboxUrlMpeg2(channel_name);
            if (url==0) setFreeboxUrlMpeg4(channel_name);
            break;
        case "mpeg42":
            setFreeboxUrlMpeg4(channel_name);
            if (url==0) setFreeboxUrlMpeg2(channel_name);
            break;
        case "mpeg4":
            setFreeboxUrlMpeg4(channel_name);
            break;
        }
        if (url==0) setFreeboxTVUrl(channel_name);
        if (url!=0) {
            if (System.Gadget.Settings.read("player") == "homeplayer") {
                // Use HomePlayer
                var HPObj = new ActiveXObject('Msxml2.XMLHTTP');
	            HPObj.open('GET', "http://127.0.0.1:8080/playmedia.jsp?MediaType=FBTV&url="+url, true);	
	            HPObj.send(null);
            } else {
                System.Shell.execute(vlc_path,"-vvv "+url);
            }
        }
    break;
    case "free-nd":
        setFreeboxTVUrl(channel_name);
        if (url!=0) {
            if (System.Gadget.Settings.read("player") == "homeplayer") {
                // Use HomePlayer
                var HPObj = new ActiveXObject('Msxml2.XMLHTTP');
	            HPObj.open('GET', "http://127.0.0.1:8080/playmedia.jsp?MediaType=WEBTV&url="+url, true);	
	            HPObj.send(null);
            } else {
                System.Shell.execute(vlc_path,"-vvv "+url);
            }
        }
    break;
    case "neuf":
        setNeufUrl(channel_name);
        if (url!=0) {
            if (System.Gadget.Settings.read("player") == "homeplayer") {
                // Use HomePlayer
                var HPObj = new ActiveXObject('Msxml2.XMLHTTP');
	            HPObj.open('GET', "http://127.0.0.1:8080/playmedia.jsp?MediaType=WEBTV&url="+url, true);	
	            HPObj.send(null);
            } else {
                System.Shell.execute(vlc_path,"-vvv "+url);
            }
        }
    break;
    case "alice":
        setAliceUrl(channel_name);
        if (url!=0) {
            if (System.Gadget.Settings.read("player") == "homeplayer") {
                // Use HomePlayer
                var HPObj = new ActiveXObject('Msxml2.XMLHTTP');
	            HPObj.open('GET', "http://127.0.0.1:8080/playmedia.jsp?MediaType=WEBTV&url="+url, true);	
	            HPObj.send(null);
            } else {
                System.Shell.execute(vlc_path,"-vvv "+url);
            }
        }
    break;
    }
    
	// Web TV
    if (url == 0) {
        // SI pas de service trouvé
        url=0;
        setStreamUrl(channel_name);
         if (url !=0) {
            if (System.Gadget.Settings.read("player") == "homeplayer") {
                // Use HomePlayer
                var HPObj = new ActiveXObject('Msxml2.XMLHTTP');
		        HPObj.open('GET', "http://127.0.0.1:8080/playmedia.jsp?MediaType=WEBTV&url="+url, true);	
		        HPObj.send(null);
            } else {
                System.Shell.execute(vlc_path,"-vvv "+url);
            }
        }    
    }
}

function isChannel(channel_name) {
    var retour = false;
    url = 0;
    if (System.Gadget.Settings.read("fai") == "free") {  
        encodage = System.Gadget.Settings.read("encodage");
        switch(encodage){
			case "mpeg2":
			    setFreeboxUrlMpeg2(channel_name); break;
            case "mpeg24":
                setFreeboxUrlMpeg2(channel_name);
                if (url== 0) setFreeboxUrlMpeg4(channel_name); break;
            case "mpeg42":
                setFreeboxUrlMpeg4(channel_name);
                if (url==0) setFreeboxUrlMpeg2(channel_name); break;
            case "mpeg4":
                setFreeboxUrlMpeg4(channel_name); break;
        }
        if (url==0) setFreeboxTVUrl(channel_name);
    } else if (System.Gadget.Settings.read("fai") == "free-nd") {
        setFreeboxTVUrl(channel_name);
    } else if (System.Gadget.Settings.read("fai") == "neuf") {
        setNeufUrl(channel_name);
    } else if (System.Gadget.Settings.read("fai") == "alice") {
        setAliceUrl(channel_name);
    }
    if (url == 0) {
        // SI pas de service trouvé
        //url=0;
        setStreamUrl(channel_name);  
    }
    if (url !=0) {
        retour = true;
    }
    return retour;
}

function setStreamUrl(channel_name) {
        switch(channel_name.toLowerCase()){
            //FR
			case '"bfm tv"':
                url="mms://vipmms9.yacast.net/bfm_bfmtv";
                break;
            case '"direct 8"':
                url="http://www.direct8.fr/live.asx.php";
            case '"france 24"':
                url="mms://live.france24.com/france24_fr.wsx";
                break;
            case '"i>tele"':
                url="mms://vipmms.itele.fr/cpi_itele";
                break;
			case 'lci':
                url="mms://tf1.yacast.net/tf1_live22";
                break;
			case '"la chaîne parlementaire"':
				url="mms://a1251.l1031033396.c10310.e.lm.akamaistream.net/D/1251/10310/666/reflector:33396";
				//url="mms://a1251.l1031033396.c10310.e.lm.akamaistream.net/D/1251/10310/666/reflector:33396"
				break;
			case 'rtl9':
				url="mms://live3.ipercast.net/abgroupe.fr/rtl9/live";
				break;
			case 'tmc':
				url="mms://live3.ipercast.net/abgroupe.fr/tmc/live";
				break;
			case '"mcm top"':
				url="mms://vipmms9.yacast.net/mcm_top";
				break;				
			case '"tele alsace"':
				url="mms://a1991.l2229962829.c22299.n.lm.akamaistream.net/D/1991/22299/v0001/reflector:36557";
				break;
			case 'tlm':
				url="mms://69.41.170.46/tlm";
				//url="mms://213.251.181.150/tlm";
				break;
			case '"orange sports tv"':
			    url="mms://livewm.orange.fr/live-multicanaux";
			    break;
			//US
			case 'eurosport':
				url="http://player.eurosport.fr/playlist.aspx?mode=live&id=6";
				break;
			case '"eurosport 2"':
				url="http://player.eurosport.fr/playlist.aspx?mode=live&id=7";
				break;
			case '"france 24"':
                url="mms://live.france24.com/france24_en.wsx";
                break;
			case 'cnbc"':
				url="mms://a1873.l2639649579.c26396.g.lm.akamaistream.net/D/1873/26396/v0001/reflector:49579";
				break;
			case '"cnn international"':
				url="http://dynamic.cnn.com/video/meta/live/stream.1.large.asx?nsfg&amp;#61;&amp;amp;CNNid&amp;#61;";
				break;
			case 'nbc':
				url="mms://msnbc.wmod.llnwd.net/a275/e1/video/100/vh.asf";
				break;
			case 'abc12':
				url="http://a1729.l2168647534.c21686.g.lm.akamaistream.net:80/D/1729/21686/v0001/reflector:52304;stream.nsv?MSWMExt=.asf";
				break;
			case '"poker channel"'://'PokerTV':
				url="http://s-lon-01a.global-mix.net/gameintv";
				break;
         }
}

function setFreeboxTVUrl(channel_name) {
    stream_id = 0;
    switch(channel_name.toLowerCase()){
        case '"france 2"':                                  stream_id="france2";    break;
        case '"france 3"':                                  stream_id="france3";    break;
        case '"france 5"':                                  stream_id="france5";    break;
        case 'arte':                                        stream_id="arte";       break;
        case '"direct 8"':                                  stream_id="direct8";    break;
        case 'nt1':                                         stream_id="nt1";        break;
        case '"nrj 12"':                                    stream_id="nrj12";      break;
        case '"la chaîne parlementaire"':                   stream_id="lcp";        break;
        case '"france 4"':                                  stream_id="france4";    break;
        case '"bfm tv"':                                    stream_id="bfmtv";      break;
        case 'tv5':                                         stream_id="tv5";        break;
        case '"france ô"':                                  stream_id="franceo";    break;
        case 'aljazeera':                                   stream_id="aljazeera";  break;
    }   
    if (stream_id !=0) {
        url = "http://tv.freebox.fr/stream_"+stream_id;
    }
}

function setFreeboxUrlMpeg4(channel_name) {
    stream_id = 0;
    switch(channel_name.toLowerCase()){
        case '"france 2"':                                  stream_id=625; break;
        //case '"france 3"':                                  stream_id=626; break;
        case '"france 3"':
            // SI une chaine régionale de France 3 est choisi ET que le MPEG4 n'est pas exclu ALORS
            if (System.Gadget.Settings.read("channelFrance3") > 0 && System.Gadget.Settings.read("channelFrance3") != 258
                && System.Gadget.Settings.read("encodage") != "mpeg4") {
                // utilisation du flux de France 3 régional en MPEG2
                                                            stream_id=0;
            } else {
                // lancement du flux de France 3 national en MPEG4
                                                            stream_id=626;
            }
            break;
        case '"france 5"':                                  stream_id=627; break;
        //case 'm6':                                        stream_id=628; break;
        case 'arte':                                        stream_id=629; break;
        case '"direct 8"':                                  stream_id=630; break;
        //case 'w9':                                        stream_id=631; break;
        case 'tmc':                                         stream_id=632; break;
        case 'nt1':                                         stream_id=633; break;
        case '"nrj 12"':                                    stream_id=634; break;
        case '"la chaîne parlementaire"':                   stream_id=635; break;
        case '"france 4"':                                  stream_id=636; break;
        case '"bfm tv"':                                    stream_id=637; break;
        case '"i>tele"':                                    stream_id=638; break;
        case '"europe 2 tv"':                               stream_id=639; break;
        case 'gulli':                                       stream_id=640; break;
    }   
    if (stream_id !=0) {
        url = "rtsp://mafreebox.freebox.fr/freeboxtv/stream?id="+stream_id;
    }
}

function setFreeboxUrlMpeg2(channel_name) {
    stream_id = 0;
    switch(channel_name.toLowerCase()){
        case '"france 2"':                                  stream_id=201; break;
        case '"france 3"':
            if (System.Gadget.Settings.read("channelFrance3") != 0) {
                var idChannel = System.Gadget.Settings.read("channelFrance3");
                                                            stream_id=idChannel;
            } else {
                                                            stream_id=202;
            }
            break;
        case '"france 5"':                                  stream_id=203; break;
        //case 'm6':                                        stream_id=613; break;
        case 'arte':                                        stream_id=204; break;
        case '"direct 8"':                                  stream_id=372; break;
        //case 'w9':                                        stream_id=373; break;
        case 'tmc':                                         stream_id=497; break;
        case 'nt1':                                         stream_id=374; break;
        case '"nrj 12"':
            if (System.Gadget.Settings.read("nrj12version") == "cinqpointun") {
                                                            stream_id=381;
            } else if (System.Gadget.Settings.read("nrj12version") == "hd") {
                                                            stream_id=617;
            } else {
                                                            stream_id=382;
            }
            break;
        case '"nrj 12 5.1"':                                stream_id=381; break;
        case '"nrj 12 stéréo"':                             stream_id=382; break;
        case '"la chaîne parlementaire"':                   stream_id=226; break;
        case '"france 4"':                                  stream_id=376; break;
        case '"bfm tv"':                                    stream_id=418; break;
        case '"i>tele"':                                    stream_id=417; break;
        case '"europe 2 tv"':                               stream_id=416; break;
        case 'gulli':                                       stream_id=419; break;
        case '"paris première"':                            stream_id=213; break;
        case 'teva':                                        stream_id=404; break;
        case 'rtl9':                                        stream_id=210; break;
        case '"ab 1"':                                      stream_id=211; break;
        case 'tv5':                                         stream_id=206; break;
        case '"france ô"':                                  stream_id=238; break;
        case '"rtbf sat"':                                  stream_id=448; break;
        case 'jet':                                         stream_id=496; break;
        case '"game one"':                                  stream_id=220; break;
        case 'mangas':                                      stream_id=253; break;
        case 'mcm':                                         stream_id=621; break;
        case '"mcm top"':                                   stream_id=622; break;
        case '"mcm pop"':                                   stream_id=623; break;        
        case '"m6 music hits"':                             stream_id=430; break;
        case '"m6 music rock"':                             stream_id=431; break;
        case '"m6 music black"':                            stream_id=432; break;
        case '"fun tv"':                                    stream_id=433; break;
        case 'mtv':                                         stream_id=219; break;
        case '"mtv 2"':                                     stream_id=229; break;
        case '"mtv base"':                                  stream_id=230; break;
        case '"mtv hits"':                                  stream_id=231; break;
        case 'vh1':                                         stream_id=233; break;
        case '"vh1 classic"':                               stream_id=232; break;
        case '"télé mélody"':                               stream_id=237; break;
        case '"trace tv"':                                  stream_id=228; break;
        case 'zik':                                         stream_id=218; break;
        case 'mezzo':                                       stream_id=265; break;
        case '"musique classique"':                         stream_id=254; break;
        case '"nrj 12 hd"':                                 stream_id=617; break;
        case '"nrj hits"':                                  stream_id=620; break;
        case 'nrj hits':                                  stream_id=620; break;
        case '"mizik tropical"':                            stream_id=468; break;
        case 'equidia':                                     stream_id=212; break;
        case '"espn classic sport"':                        stream_id=264; break;
        case '"ab moteurs"':                                stream_id=222; break;
        case '"motors tv"':                                 stream_id=216; break;
        case '"poker channel"':                             stream_id=618; break;
        case '"real madrid tv"':                            stream_id=387; break;
        case 'euronews':                                    stream_id=205; break;
        case '"bloomberg tv"':                              stream_id=207; break;
        case '"al jazeera international"':                  stream_id=494; break;
        case '"bbc world"':                                 stream_id=240; break;
        case '"sky news international"':                    stream_id=355; break;
        case 'tna':                                         stream_id=482; break;
        case '"zalea tv"':                                  stream_id=483; break;
        case 'kto':                                         stream_id=223; break;
        case '"berbère tv"':                                stream_id=256; break;
        case '"beur tv"':                                   stream_id=225; break;
        case '"demain !"':                                  stream_id=227; break;
        case '"fashion tv"':                                stream_id=221; break;
        case '"f men"':                                     stream_id=454; break;
        case '"sailing channel"':                           stream_id=255; break;
        case '"liberty tv"':                                stream_id=215; break;
        case 'animaux':                                     stream_id=248; break;
        case '"chasse et pêche"':                           stream_id=249; break;
        case 'encyclopédia':                                stream_id=251; break;
        case 'escales':                                     stream_id=252; break;
        case '"toute l\'histoire"':                         stream_id=250; break;
        case 'histoire':                                    stream_id=235; break;
        case '"3a telesud"':                                stream_id=356; break;
        case 'luxe.tv':                                     stream_id=460; break;
        case '"freenews tv"':                               stream_id=428; break;
        case 'action':                                      stream_id=242; break;
        case '"ciné polar"':                                stream_id=244; break;
        case '"ciné fx"':                                   stream_id=243; break;
        case '"best of shopping"':                          stream_id=358; break;
        case '"m6 boutique"':                               stream_id=359; break;
        case '"astro center tv"':                           stream_id=415; break;
        case '"terre d\'infos"':                            stream_id=437; break;
        case 'tlm':                                         stream_id=267; break;
        case 'tlt':                                         stream_id=281; break;
        case '"tv7 bordeaux"':                              stream_id=268; break;
        case '"tv8 mont-blanc"':                            stream_id=319; break;
        case 'télégrenoble':                                stream_id=423; break;
        case 'telif':                                       stream_id=360; break;
        case '"la locale"':                                 stream_id=363; break;
        case '"normandie tv"':                              stream_id=383; break;
        case '"télénantes nantes 7"':                       stream_id=389; break;
        case '"la chaîne marseille"':                       stream_id=414; break;
        case '"clermont première"':                         stream_id=438; break;
        case '"tv tours"':                                  stream_id=493; break;
        case 'cctv4':                                       stream_id=469; break;
        case '"cctv 9"':                                    stream_id=479; break;
        case '"cctv e&f"':                                  stream_id=480; break;
        case '"cctv divertissement"':                       stream_id=470; break;
        case '"beijing tv"':                                stream_id=472; break;
        case '"shangai dragon tv"':                         stream_id=473; break;
        case '"la chaîne internationale de jiangsu"':       stream_id=474; break;
        case '"hunan satellite tv"':                        stream_id=475; break;
        case '"xiamen star tv"':                            stream_id=476; break;
        case '"zhejiang star tv"':                          stream_id=477; break;
        case '"guangdong southern tv"':                     stream_id=478; break;
        case '"phoenix infonews"':                          stream_id=481; break;
        case '"phoenix chinese news and entertainment"':    stream_id=266; break;
        case '"zee tv"':                                    stream_id=420; break;
        case '"zee cinema"':                                stream_id=421; break;
        case '"alpha etc punjabi"':                         stream_id=422; break;
        case '"euronews english"':				            stream_id=259; break;
        case '"euronews deutsch"': 			                stream_id=260; break;
        case '"euronews portugais"':               			stream_id=261; break;
        case '"euronews russe"':							stream_id=262; break;
        case '"euronews espagnol"':							stream_id=263; break;
        case '"euronews italien"':               			stream_id=269; break;
        case 't.tv':               							stream_id=385; break;
        case '"bbc prime europe"':               			stream_id=413; break;
        case '"god tv"':                					stream_id=386; break;
        case '"arte allemand"':               				stream_id=270; break;
        case 'dw-tv':               						stream_id=312; break;
        case '"ritmoson latino"':               			stream_id=407; break;
        case '"de pelicula"':               				stream_id=408; break;
        case '"tl novelas"':               					stream_id=409; break;
        case '"canal de las estrellas"':               		stream_id=410; break;
        case '"telehit"':               					stream_id=411; break;
        case '"tve i"':              						stream_id=306; break;
        case '"canal 24 horas"':               				stream_id=307; break;
        case '"etb sat"':               					stream_id=371; break;
        case 'tvci':               							stream_id=461; break;
        case 'sic':               							stream_id=484; break;
        case 'rtpi':               							stream_id=388; break;
        case '"rai uno"':               					stream_id=309; break;
        case '"rai due"':               					stream_id=314; break;
        case '"rai tre"':               					stream_id=315; break;
        case '"rtr planeta"':               				stream_id=317; break;
        case 'orti':               							stream_id=357; break;
        case '"nashe kino"':               					stream_id=441; break;
        case '"detski mir/teleclub"':               		stream_id=442; break;
        case 'rtvi':               							stream_id=443; break;
        case 'rtvi-m':               						stream_id=444; break;
        case '"tv romania"':                                stream_id=318; break;
        case '"bulgaria tv"':                               stream_id=321; break;
        case '"georgian tv"':                               stream_id=487; break;
        case '"adjara tv"':                                 stream_id=316; break;
        case '"imedi tv"':                                  stream_id=488; break;
        case '"ntv hayat"':                                 stream_id=429; break;
        case '"rtv pink plus"':                             stream_id=439; break;
        case '"rtv pink extra"':                            stream_id=440; break;
        case '"tv biznes"':                                 stream_id=450; break;
        case '"tv polonia"':                                stream_id=278; break;
        case '"tvp Kultura"':                               stream_id=485; break;
        case '"tvp 3"':                                     stream_id=486; break;
        case '"armenia public tv"':                         stream_id=380; break;
        case '"2m maroc"':                                  stream_id=272; break;
        case '"rtm maroc"':                                 stream_id=273; break;
        case '"canal algérie"':                             stream_id=274; break;
        case '"tv7 tunisia"':                               stream_id=277; break;
        case '"al masriya"':                                stream_id=275; break;
        case '"al jazeera"':                                stream_id=276; break;
        case '"al jazeera children"':                       stream_id=412; break;
        case '"art variety europe"':                        stream_id=326; break;
        case '"art teenz/tarab"':                           stream_id=327; break;
        case '"art movies"':                                stream_id=328; break;
        case '"al hekayat"':                                stream_id=330; break;
        case 'iqra':                                        stream_id=331; break;
        case '"art aflam 2"':                               stream_id=332; break;
        case '"future tv"':                                 stream_id=333; break;
        case 'mbc':                                         stream_id=334; break;
        case '"lbc europe"':                                stream_id=335; break;
        case '"nile drama"':                                stream_id=336; break;
        case '"the israeli network"':                       stream_id=462; break;
        case '"powertürk tv"':                              stream_id=489; break;
        case 'trt1':                                        stream_id=490; break;
        case '"kanal d"':                                   stream_id=463; break;
        case '"star tv"':                                   stream_id=464; break;
        case 'tgrt':                                        stream_id=465; break;
        case '"ntv avrupa"':                                stream_id=466; break;
        case '"atv avrupa"':                                stream_id=467; break;
        case 'td1':                                         stream_id=435; break;
        case '"trt int"':                                   stream_id=369; break;
        case '"kanal 7 int"':                               stream_id=370; break;
        case '"samanyolu tv"':                              stream_id=391; break;
        case 'tvt':                                         stream_id=436; break;
        case 'tv5':                                         stream_id=446; break;
        case '"kanal avrupa"':                              stream_id=447; break;
        case '"france 3 national"':                         stream_id=258; break;
        case '"france 3 alsace"':                           stream_id=280; break;
        case '"france 3 alpes"':                            stream_id=283; break;
        case '"france 3 aquitaine"':                        stream_id=284; break;
        case '"france 3 auvergne"':                         stream_id=285; break;
        case '"france 3 bourgogne"':                        stream_id=279; break;
        case '"france 3 bretagne"':                         stream_id=286; break;
        case '"france 3 centre"':                           stream_id=287; break;
        case '"france 3 champagne-ardenne"':                stream_id=288; break;
        case '"france 3 corse"':                            stream_id=289; break;
        case '"france 3 côte-d\'azur"':                     stream_id=290; break;
        case '"france 3 franche-comté"':                    stream_id=291; break;
        case '"france 3 languedoc-roussillon"':             stream_id=292; break;
        case '"france 3 limousin"':                         stream_id=293; break;
        case '"france 3 lorraine"':                         stream_id=294; break;
        case '"france 3 midi pyrénées"':                    stream_id=295; break;
        case '"france 3 nord pas-de-calais"':               stream_id=296; break;
        case '"france 3 haute-normandie"':                  stream_id=297; break;
        case '"france 3 basse-normandie"':                  stream_id=298; break;
        case '"france 3 paris ile-de-france"':              stream_id=257; break;
        case '"france 3 pays de loire"':                    stream_id=299; break;
        case '"france 3 picardie"':                         stream_id=300; break;
        case '"france 3 poitou-charentes"':                 stream_id=301; break;
        case '"france 3 provence-alpes"':                   stream_id=302; break;
        case '"france 3 rhône-alpes"':                      stream_id=303; break;
        case '"mire freebox"':                              stream_id=308; break;
    }
    if (stream_id==0) {
        stream_id=channel_name.toLowerCase();
    }
    if (stream_id !=0) {
        url = "rtsp://mafreebox.freebox.fr/freeboxtv/stream?id="+stream_id;
    }
}

function setNeufUrl(channel_name) {       
   stream_id = 0;
   switch(channel_name.toLowerCase()){
        case '"france 2"':                                  stream_id="france_2"; break;
        case '"france 3"':                                  stream_id="france_3"; break;
        case '"france 5"':                                  stream_id="france_5"; break;
        case 'arte':                                        stream_id="arte"; break;
        case '"direct 8"':                                  stream_id="direct_8"; break;
        case 'nt1':                                         stream_id="nt1"; break;
        case '"nrj 12"':                                    stream_id="nrj12"; break;
        case '"la chaîne parlementaire"':                   stream_id="lcp"; break;
        case '"france 4"':                                  stream_id="france_4"; break;
        case '"bfm tv"':                                    stream_id="bfm_tv"; break;
        case 'jet':                                         stream_id="jet"; break;
        case 'tv5':                                         stream_id="tv5_monde"; break;
        case '"france o"':                                  stream_id="france_o"; break;
        case 'euronews':                                    stream_id="euronews"; break;
        case 'aljazeera':                                   stream_id="aljazeera"; break;
        case '"liberty tv"':                                stream_id="liberty_tv"; break;
        case 'tfou':                                        stream_id="tfou"; break;
        case '"beur tv"':                                   stream_id="beur_tv"; break;
        case '"nrj hits"':                                  stream_id="nrj_hits"; break;
        case '"video click"':                               stream_id="video_click"; break;       
    }
    if (stream_id !=0) {
        url = "http://80.118.196.219/webtv-asx.cgi?channel="+stream_id;
    }  
}

function setAliceUrl(channel_name) {       
   stream_id = 0;
   switch(channel_name.toLowerCase()){
        case '"france 2"':                                  stream_id="France2"; break;
        case '"france 3"':                                  stream_id="France3"; break;
        case '"france 5"':                                  stream_id="France5"; break;
        case '"france 4"':                                  stream_id="France4"; break;
        case '"france o"':                                  stream_id="FranceO"; break;
        case '"liberty tv"':                                stream_id="LibertyTV"; break;
        case '"la chaîne parlementaire"':                  stream_id="LCP"; break;
       	case '"fashion tv"':                                stream_id="FashionTV"; break;
       	case '"demain !"':                                  stream_id="DemainTV"; break;
       	case 'kto':                                         stream_id="KTO"; break;
       	case 'luxe.tv':                                     stream_id="LuxeTV"; break;
    }
    if (stream_id !=0) {
        url = "mms://62.210.4.193/"+stream_id;
    }  
}

function showFlyout(obj) {
    
    /*if(event.type == "click") {
		
		if (System.Gadget.Flyout.show == true) {
			System.Gadget.Flyout.show = false;
		} else {
		
			var tmp = document.getElementById(obj).innerHTML;
		    var channel_name;
		    
		    if (isFreeboxConnection) {
		    
		        if (tmp.substring(0,1) == '<') {
		            var debut = tmp.indexOf('alt=',0)+4;
		            var fin = tmp.indexOf(' src=',debut);
		            channel_name = tmp.substring(debut,fin);
		        } else {
		            channel_name = tmp;
		        }

		        url = 0;
		        setFreeboxUrl(channel_name);
		        if (url !=0) {
		            //System.Gadget.Flyout.file = "Flyout.html";
		            System.Gadget.Flyout.show = true;
		            var flyoutDiv =  System.Gadget.Flyout.document;
					flyoutDiv.getElementById("flyoutMain").innerHTML = 
					'<OBJECT classid="clsid:E23FE9C6-778E-49D4-B537-38FCDE4887D8"' +
            'codebase="http://downloads.videolan.org/pub/videolan/vlc/latest/win32/axvlc.cab#Version=0,8,6,0"' +
            'width="320" height="240" id="vlc" events="True">' +
            '<param name="Src" value="'+url+'" />' +
            '<param name="ShowDisplay" value="True" />' +
            '<param name="AutoLoop" value="False" />' +
            '<param name="AutoPlay" value="True" />' +
        '</OBJECT>';
					
					/*flyoutDiv.vlc.playlistClear();
		            var options=[":audio-track=0"]; // select audio track 5 (=6th, 1st is 0)		         
		            flyoutDiv.vlc.addTarget(url ,options, 2, 0);
		            //vlc.addTarget("rtsp://mafreebox.freebox.fr/freeboxtv/stream?id=201","[]",2,0); // replace entry 0		         
		            flyoutDiv.vlc.play();*

					
		        }   
		    }
		}
	}*/
}
function onLoadFlyout() {
        /*if (url !=0) {
         //var vlc = getVLC("vlc");
            vlc.playlistClear();
         
            var options=[":audio-track=0"]; // select audio track 5 (=6th, 1st is 0)
         
            vlc.addTarget(url ,options, 2, 0);
            //vlc.addTarget("rtsp://mafreebox.freebox.fr/freeboxtv/stream?id=201","[]",2,0); // replace entry 0
         
            vlc.play();
        }*/
    }
/*function onLoadFlyout() {
    if (url !=0) {
            
         document.getElementById("vlc");
         //.playlistClear();
         //var options=[":audio-track=5"]; // select audio track 5 (=6th, 1st is 0)
        document.getElementById("vlc").addTarget(url,"",2,0); // replace entry 0
         document.vlc.play();
         
            
         /*document.getElementById("flyoutbody").innerHTML =
            '<OBJECT classid="clsid:9BE31822-FDAD-461B-AD51-BE1D1C159921"' +
            'codebase="http://downloads.videolan.org/pub/videolan/vlc/latest/win32/axvlc.cab#Version=0,8,6,0"' +
            'width="320" height="240" id="vlc" events="True">' +
            '<param name="Src" value="'+url+'" />' +
            '<param name="ShowDisplay" value="True" />' +
            '<param name="AutoLoop" value="False" />' +
            '<param name="AutoPlay" value="True" />' +
            '</OBJECT>';*
            
            }            

}*/

function closeFlyout() {
    System.Gadget.Flyout.show = false;
}